package com.atguigu.service.Impl;

import com.atguigu.dao.Impl.UserDaoImpl;
import com.atguigu.dao.UserDao;
import com.atguigu.pojo.User;
import com.atguigu.service.UserService;

/**
 * @ClassName UserServiceImpl
 * @Description 业务接口的实现类
 * @Author 周轩霆
 * @Date 2022/4/9 19:25
 **/

public class UserServiceImpl implements UserService {
//多态方式的实例化，用到dao层的方法
    private UserDao userDao=new UserDaoImpl();

    @Override
    public void registerUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(),user.getPassword());
        
    }

    @Override
    public boolean existsUsername(String username) {
        if(userDao.queryUserByUsername(username)==null){
            //不存在，查不到，可以用
          return  false;
        }
        return true;
    }
}
